package com.xudow.app.dynamicstate_old.widget.exview;

import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.squareup.picasso.Picasso;

public class NetImagePieceView extends PieceView {
    private ImageView mImageView;
    Context context;

    public NetImagePieceView(Context context) {
        super(context);
        init(context);
    }

    public NetImagePieceView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public NetImagePieceView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        this.context = context;
        mImageView = new ImageView(getContext());
        mImageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        addView(mImageView);
    }

    public void setImageUri(Uri uri) {
        Glide.with(context).load(uri)
                .into(mImageView);
    }

    public void setImage(String path) {
        Glide.with(context).load(path)
                .into(mImageView);
    }
}